﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebManager;
using System.Data;

namespace BaoJian.WebManager.Function.ClassifyProducts
{
    public partial class List : System.Web.UI.Page
    {

        private LYQ.BLL.ClassifyProducts bll = new LYQ.BLL.ClassifyProducts();
        private string ColumnID = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            ColumnID = HttpContext.Current.Request.QueryString["oid"];
            if (!Page.IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            DataSet ds = bll.GetList(" 1=1 order by ProductName,SID desc");
            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            BindData();
        }

        protected void Add_Click(object sender, EventArgs e)
        {
            string url = URLUtility.UrlBase + "/WebManager/Function/ClassifyProducts/Add.aspx?ColumnID=" + ColumnID;
            Page.Response.Redirect(url);
        }

        protected void Delete_Click(object sender, EventArgs e)
        {
            string sel = HttpContext.Current.Request.Form["selectCB"];
            if (sel == null)
            {
                return;
            }
            string[] sels = sel.Split(',');
            for (int i = 0; i < sels.Length; i++)
            {
                bll.Delete(Convert.ToInt32(sels[i]));
            }
            BindData();
            string url = URLUtility.UrlBase + "/WebManager/Function/ClassifyProducts/List.aspx?ColumnID=" + ColumnID;
            Page.Response.Redirect(url);
        }

    }
}
